#!/bin/bash
PROJECTFLAG=release
MOUT:=@
CC=$(MOUT)gcc -g -Wall #-nostartfiles -e mymain 
RM=$(MOUT)rm -rf
SOURCE_PATH:=#./
BUILD_PATH:=#./
STATIC_TARGET:=a
CFLAGS:=-lpthread
CFLAGS+=-lm -L./
INCL=# ./ #../module/threadpool
# 排除文件列表
# EXCLUDES := $(shell cat ./exclude.txt)
# NEWSRC:= $(filter-out $(EXCLUDES),$(SRC))
# SOURCE := $(filter-out tst.c, $(wildcard $(SOURCE_PATH)*.c))

EXCLUDES := cJSON.c main.c 
SOURCE := $(filter-out $(EXCLUDES), $(wildcard $(SOURCE_PATH)*.c))
# SOURCE := $(wildcard $(SOURCE_PATH)*.c)
OBJS := $(patsubst %.c, $(BUILD_PATH)%.o, $(notdir $(SOURCE)))

all:$(STATIC_TARGET)
ifeq (release, $(PROJECTFLAG))
#@echo "发布版本"
#@strip $(STATIC_TARGET)
else
#@echo "DEBUG版本"
endif

#生成二进制文件(*.o)	
$(OBJS): $(BUILD_PATH)%.o:$(SOURCE_PATH)%.c
	$(CC) -c -Wall $(INCL) $< -o $@ $(CFLAGS)

#生成静态二进制文件
$(STATIC_TARGET):$(OBJS)
	$(CC) $(OBJS) -o $(STATIC_TARGET) $(CFLAGS)

clean:
	$(RM) $(OBJS) $(STATIC_TARGET)

.PHONY:all
